extends Area2D

@export var value:int=3

@onready var player:CharacterBody2D = $'/root/Player'
@onready var sprite:AnimatedSprite2D = $AnimatedSprite2D
@onready var pickup_sound = $PickupSound
func _ready():
	self.body_entered.connect(_on_body_entered)
	
func _process(delta):
	pass

func _on_body_entered(body):
	if body.is_in_group('player'):
		body.add_ammo(value)
		sprite.play('collected')
		pickup_sound.play()
		sprite.animation_finished.connect(_on_animation_finished)

func _on_animation_finished():
	queue_free()
